﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QUAN_LY_MUON_TRA_SACH
{
    public partial class frmphieu_muon : Form
    {
        public frmphieu_muon()
        {
            InitializeComponent();
        }

        private void frmphieu_muon_Load(object sender, EventArgs e)
        {
            DataTable bang1 = new DataTable();
            SqlDataAdapter lenh = new SqlDataAdapter("select b.ISBN,b.STT_CUON,TUASACH,LAN_GIA_HAN,RTRIM(CAST((DATEPART(DAY,NGAY_HET_HAN)) AS CHAR(5)))+'/'+RTRIM(CAST((DATEPART(MONTH,NGAY_HET_HAN)) AS CHAR(5)))+'/'+CAST((DATEPART(YEAR,NGAY_HET_HAN)) AS CHAR(5)) AS NGAY_HET_HAN,HTEN_DG,RTRIM(CAST((DATEPART(DAY,NGAY_GIO_MUON)) AS CHAR(5)))+'/'+RTRIM(CAST((DATEPART(MONTH,NGAY_GIO_MUON)) AS CHAR(5)))+'/'+CAST((DATEPART(YEAR,NGAY_GIO_MUON)) AS CHAR(5)) AS NGAYMUON from phieu_muon a,gom_cuon b,the_doc_gia c,cuon_sach d,dau_sach e where d.isbn=e.isbn and b.isbn=d.isbn and b.stt_cuon=d.stt_cuon and a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and ngay_gio_tra is null and a.mathe='" + frmmuonsach.mathe + "' and a.stt_phieu=(select max(stt_phieu) from phieu_muon where mathe='" + frmmuonsach.mathe + "')", Connection.sqlConnection);
            lenh.Fill(bang1);
            rpt_phieu_muon bc1 = new rpt_phieu_muon();
            bc1.DataSource = bang1;
            bc1.BindData();
            printControl1.PrintingSystem = bc1.PrintingSystem;
            bc1.CreateDocument(); 
        }
    }
}
